{{ if eq .Section "search" }}
<script defer src="https://cdn.jsdelivr.net/npm/art-template@4.13.2/lib/template-web.min.js" integrity="sha512-/8K8Hs4pVcqd/wI87fQEzHCeGZVYPo3vMbmf8GzT3nQec19dfHVnRwBZHvkkzjaQSO9vpilow841VfvE6b86Lw==" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/fuse.js@6.5.3/dist/fuse.min.js" integrity="sha512-W+QdO2uEYG8oKLFGKPGGwT43RQWOBzAcxSpPMRyR6zAC3DLjMPp6GxoPvasKfs1pbYYXd0ByDCOiBd7M554qbw==" crossorigin="anonymous"></script>
{{ else if eq .Section "archives" }}
{{ else }}
<script defer src="https://cdn.jsdelivr.net/npm/medium-zoom@1.0.6/dist/medium-zoom.min.js" integrity="sha512-N9IJRoc3LaP3NDoiGkcPa4gG94kapGpaA5Zq9/Dr04uf5TbLFU5q0o8AbRhLKUUlp8QFS2u7S+Yti0U7QtuZvQ==" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/lazysizes@5.3.2/lazysizes.min.js" integrity="sha512-q583ppKrCRc7N5O0n2nzUiJ+suUv7Et1JGels4bXOaMFQcamPk9HjdUknZuuFjBNs7tsMuadge5k9RzdmO+1GQ==" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/prismjs@1.27.0/components/prism-core.min.js" integrity="sha512-LCKPTo0gtJ74zCNMbWw04ltmujpzSR4oW+fgN+Y1YclhM5ZrHCZQAJE4quEodcI/G122sRhSGU2BsSRUZ2Gu3w==" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/prismjs@1.27.0/plugins/autoloader/prism-autoloader.min.js" integrity="sha512-GP4x8UWxWyh4BMbyJGOGneiTbkrWEF5izsVJByzVLodP8CuJH/n936+yQDMJJrOPUHLgyPbLiGw2rXmdvGdXHA==" crossorigin="anonymous"></script>
{{ end }}
{{ $options := (dict "targetPath" "assets/js/fuji.min.js" "minify" true "target" "es2015" "format" "iife") }}
{{ $built := resources.Get "js/fuji.js" | js.Build $options | resources.Fingerprint "sha512" }}
<script defer src="{{ $built.RelPermalink }}" integrity="{{ $built.Data.Integrity }}"></script>
{{ if or .Params.math .Site.Params.math }}
{{ partial "math.html" . }}
{{ end }}
{{ with .Params.aplayer }}
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js" integrity="sha512-RWosNnDNw8FxHibJqdFRySIswOUgYhFxnmYO3fp+BgCU7gfo4z0oS7mYFBvaa8qu+axY39BmQOrhW3Tp70XbaQ==" crossorigin="anonymous"></script>
<script>
  (function () {
    function parseBasePath(basePath, rawURL) {
      if (!/^\/[^/]/.test(rawURL)) {
        return rawURL;
      }
      return rawURL.replace(/^\//, basePath + '/').replace(/\/\//g, '/');
    }
    // in-post aplayer
    var pContainers = document.querySelectorAll('.content article .post-aplayer');
    if (pContainers && pContainers.length > 0) {
      pContainers.forEach(function (container) {
        var attrs = ['urls', 'names', 'artists', 'covers', 'base'];
        attrs = attrs.map(function (attr) {
          var arr = container.getAttribute('data-' + attr).replace(/( |%20)/ig, '').split(',');
          if (arr.length > 0){
            return arr.map(function (val) {
              return String(val).trim();
            });
          } else {
            return attr;
          }
        });
        var basePath = new URL(attrs[4][0] || '/', 'https://example.org').pathname;
        var audio = [];
        for (var i = 0; i < attrs[0].length; i++) {
          var a = {
            name: attrs[1][i],
            url: parseBasePath(basePath, attrs[0][i]),
          };
          (typeof attrs[2] !== 'string') && (a.artist = attrs[2][i]);
          (typeof attrs[3] !== 'string') && (a.cover = parseBasePath(basePath, attrs[3][i]));
          audio.push(a);
        }
        new APlayer({
          container: container,
          theme: '#8f82bc',
          volume: 0.1,
          listFolded: true,
          audio: audio
        });
      });
    }
    // aplayer toc anchors fix
    // see https://github.com/MoePlayer/APlayer/issues/242#issuecomment-602471423
    document.addEventListener('DOMContentLoaded', function () {
      var issueTocEle = document.querySelector('.sidebar-toc');
      if (issueTocEle) {
        var newTocEle = issueTocEle.cloneNode(true);
        issueTocEle.parentNode.replaceChild(newTocEle, issueTocEle);
      }
    });
  })();
</script>
{{ end }}
